package com.dxq.springcloud.service;

import com.dxq.springcloud.pojo.Dept;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;
//降级
public class DeptClientServiceFallbackFactory implements FallbackFactory {
    @Override
    public Object create(Throwable cause) {
        return new DeptClientService() {
            @Override
            public boolean addDept(Dept dept) {
                return false;
            }
            @Override
            public Dept queryId(Long id) {
                return new Dept()
                        .setDeptno(id)
                        .setDname("id=>"+id+"没有对应的信息，客户端提供了降级的信息，这个服务现在已经被关闭了")
                        .setDb_source("没有数据");
            }
            @Override
            public List queryAll() {
                return null;
            }
        };
    }
}
